﻿using System;
using System.Diagnostics.Contracts;

namespace GIMS.Def.Arguments
{
    public enum PathType
    {
        load,
        save
    }

    public class PathArgument : Argument
    {
        private string path = "";
        private PathType pathType;
        private bool isParameter;

        public PathArgument(PathType pt)
        {
            name = "Path Argument";
            type = Flags.ArgumentType.path;
            pathType = pt;
            isParameter = false;
        }

        public override string CreateScriptPart()
        {
            if (string.IsNullOrEmpty(path))
            {
                return "";
            }

            if (IsParameter == true)
            {
                if (pathType == PathType.load)
                {
                    return "%1.%2";
                }
                else
                {
                    return "%1-%3.%2";
                }
            }

            return String.Concat(@"""", path, @"""");
        }

        public String Path
        {
            get { return path; }
            set
            {
                Contract.Requires(!string.IsNullOrEmpty(value));
                path = value;
                OnPropertyChanged("Path");
            }
        }

        public PathType PathType
        {
            get { return pathType; }
        }

        public bool IsParameter
        {
            get { return isParameter; }
            set
            {
                isParameter = value;
                OnPropertyChanged("IsParameter");
            }
        }
    }
}
